package dfs;

public class CountSubstrings647 {
    int count=0;
    public int countSubstrings(int[] nums, int s) {
        dfs(nums,s,0,0);
        return count;
    }

    private void dfs(int[] nums, int s, int sum, int index) {
        if(index==nums.length){
            if(sum==s){
                count++;
            }
        }else{
            dfs(nums, s, sum+nums[index], index+1);
            dfs(nums, s, sum-nums[index], index+1);
        }
    }
}
